﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace JLM2
{
    public static class JLMLog
    {
        static private FileStream jlLogFile = null;

        static public bool Open(string logFile, bool mutexLog)
        {
            if (!File.Exists(@"jlm.log"))
            {
                return false;
            }

            File.Delete(@"jlm.log");
            jlLogFile = new FileStream(@"jlm.log", FileMode.Create);

            return true;
        }


        static public void Write(string log)
        {
            //开始写入
            byte[] buffer = Encoding.ASCII.GetBytes(log);
            jlLogFile.Write(buffer, 0, buffer.Length);
            //清空缓冲区、关闭流
            jlLogFile.Flush();
        }

        static public void Close()
        {
            jlLogFile.Close();
        }
    }
}
